<?php
/**
 * Created by PhpStorm.
 * User: Silence
 * Date: 2017-07-15
 * Time: 21:50
 */

namespace App\Http\Controllers\AreaMaster;

use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\DB;

class AreaMoneyController extends Controller
{
    public function searchMoney()
    {

        $data['area'] = DB::table('area')
            ->where('area_id','=',session('employee_area'))
            ->first();
        $data['nowArea'] = $data['area']->area_name; //获取当前区域名称

        $data['areaData'] = DB::table('area')->get();
        $data['moneyData'] =DB::table('task')
            ->where('task_area','=',session('employee_area'))
            ->leftJoin('area','area_id','=','task_area')
            ->leftJoin('customer','customer_id','=','task_customer')
            ->get();
        $data['nowMoney'] =DB::table('task')
            ->where('task_area','=',session('employee_area'))
            ->leftJoin('area','area_id','=','task_area')
            ->leftJoin('customer','customer_id','=','task_customer')
            ->sum('task_money');


        return view("/areaMaster.searchMoney",$data);
    }
}